/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.camachosanchez.gui.desktop;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.swing.JDesktopPane;

/**
 *
 * @author Rolando
 */
public class MyDesktop extends JDesktopPane {

    private Image backImage = null; //member variable
    private Image titleImage = null; //member variable

    public MyDesktop() {
        try {
            setBackground(new Color(205, 223, 237));
            titleImage = new javax.swing.ImageIcon(this.getClass().getResource("/com/camachosanchez/recursos/titulo.png")).getImage();
            backImage = new javax.swing.ImageIcon(this.getClass().getResource("/com/camachosanchez/recursos/truck.jpg")).getImage();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void paintComponent(Graphics g) {
//        if (backImage == null) {
        super.paintComponent(g);
//        } else {
        Graphics2D g2d = (Graphics2D) g;
        //scale the image to fit the size of the Panel
        int mw = backImage.getWidth(null);
        int mh = backImage.getHeight(null);
        int tw = titleImage.getWidth(null);
        int th = titleImage.getHeight(null);
        int sw = getWidth();
        int sh = getHeight();
//        g2d.setColor(new Color(180, 180, 180));
        g2d.setColor(new Color(203, 219, 234));
//        g2d.setColor(Color.gray);
//        g2d.setColor(Color.white);
        g2d.fillRect(0, 0, sw, sh);
        //g2d.drawImage(backImage, (sw - mw), (sh - mh), this);
        //g2d.drawImage(titleImage, (sw - tw) / 2, 10, this);
//        }
    }
}
